package com.gaoyuzhe.message.impl;

import cn.hutool.core.lang.UUID;
import com.gaoyuzhe.message.IMessageService;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

/**
 * @author gaoyuzhe
 */
@EnableBinding(Source.class)
public class MessageServiceImpl implements IMessageService {

    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String uuid = UUID.fastUUID().toString();
        output.send(MessageBuilder.withPayload(uuid).build());
        System.out.println("信息发送成功！"+uuid);
        return uuid;
    }

}
